﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.ComponentModel;

namespace Data.DataGet
{
    public class _MucDT
    {
        DataProvider ob = new SQLProvider();
        public DataTable DataHangTon()
        {
            DataTable ds = new DataTable();
            string strSQL = "select TenDT as 'Ten Dien Thoai',MaDT as 'Ma Dien Thoai',SoLuong as 'So Luong Hien Co Trong Kho' from DanhMucDT ";
            return ds = ob.Execute_Table(strSQL);
        }
        public void Update_DanhMucDT(string TenDT, string MaDT, string BangTan, string TinhNang, string BoNho, string CongKetNoi, int SoLuong, string ThoiGianBH)
        {
            string SPName = "update_DanhMucDT";
            SqlParameter[] para = new SqlParameter[9];
            para[0] = new SqlParameter("@MaDT_0", MaDT);
            para[1] = new SqlParameter("@TenDT", TenDT);
            para[2] = new SqlParameter("@MaDT", MaDT);
            para[3] = new SqlParameter("@BangTan", BangTan);
            para[4] = new SqlParameter("@TinhNang", TinhNang);
            para[5] = new SqlParameter("@BoNho", BoNho);
            para[6] = new SqlParameter("@CongKetNoi", CongKetNoi);
            para[7] = new SqlParameter("@SoLuong", SoLuong);
            para[8] = new SqlParameter("@ThoiGianBH", ThoiGianBH);
            ob.Execute_Modify(SPName, para);
        }
        public DataTable TimKiemDienThoai(string s)
        {
            DataTable ds = new DataTable();
            string strSQL = "select TenDT as 'Tên Điện Thoại',MaDT as 'Mã Điện Thoại',TinhNang as 'Tính Năng Chính',SoLuong as 'Số Lượng Hiện Có',ThoiGianBH as 'Thời Gian Bảo Hành' from DanhMucDT where TenDT like '%" + s + "%' or MaDT like '%" + s + "%' or BangTan like '%" + s + "%' or TinhNang like '%" + s + "%' or BoNho like '%" + s + "%' or CongKetNoi like '%" + s + "%' or ThoiGianBH like '%" + s + "%'";
            return ds = ob.Execute_Table(strSQL);
        }
    }
}
